package platform.common.client.impl;

import platform.common.client.IBusinessClient;
import platform.common.dao.impl.CriticalTechnicalDaoException;
import platform.common.dao.impl.DaoConfigException;
import platform.common.dao.impl.DaoException;
import platform.common.dao.impl.TechnicalDaoException;
import platform.common.exception.BusinessException;
import platform.common.exception.CriticalTechnicalException;
import platform.common.exception.InValidDataException;
import platform.common.exception.TechnicalException;

public class BaseBizClientImpl implements IBusinessClient {

	/* (non-Javadoc)
	 * @see platform.common.client.IBusinessClient#handleBusinessClientException(java.lang.Exception, java.lang.String)
	 */
	public BusinessException handleBusinessClientException(String errMsg, Exception e) {
		if(e instanceof CriticalTechnicalDaoException) {
			return new CriticalTechnicalException(e);
		} else if(e instanceof TechnicalDaoException) {
			return new TechnicalException(e);
		} else if(e instanceof DaoConfigException) {
			return new CriticalTechnicalException(e);
		} else if(e instanceof DaoException) {
			return new TechnicalException(e);
		} else if(e instanceof InValidDataException) {
			return (InValidDataException) e;
		}  else if(e instanceof BusinessException) {
			return (BusinessException) e;
		} else {
			return new BusinessException(errMsg, e);
		}
	}

	/* (non-Javadoc)
	 * @see platform.common.client.IBusinessClient#handleBusinessClientException(java.lang.Exception)
	 */
	public BusinessException handleBusinessClientException(Exception e) {
		return this.handleBusinessClientException("", e);
	}

}
